Welcome to the 4th Module
of how to build chatbots. In this module, we
will finally address the third component of
our dialogues skill, namely the dialogue itself. The dialogue component
allows us to issue a response to the user
based on the basis of their intent and
the specifics of their request which we captured through entities we defined. It's great that our chatbot can detect and classify
the user input. However, so far
we haven't really replied to the user at all. We must be able to act on that correct classification by issuing an appropriate response. When a user greets
us for example, we may want to reply back with. Hi there. How can I help you? The same is true for
more complex queries. We must be able to use the fine-tuned
classification that intents and entities
enabled us to do, to provide an appropriate and accurate response
to the user. In this case, they
inquired about our Toronto store hours and the response would
reflect that and contain the information
the user is looking for. A dialogue is simply
a tree of nodes and each node will typically handle
one particular scenario, for example here we
have three nodes. The first one is welcome which handles the
chatbot prompt. In other words, our greeting
when the first user arrives. Then we have a greetings node to respond to the user greeting us. Finally, we have a special fallback
node that will notify the user that the chatbot wasn't quite sure about what
the user was asking. Welcome, and anything else
are two default nodes created for you when you first create the dialogue
for your chatbot. Any node you will define will
sit in-between these two, but let's take a quick look at what a node might look like. You'll want to give
each node a name. Watson doesn't really
care about the node name, but it's useful to us, the chatbot designers,
so that we can more easily organize and
work with our nodes. Next, we'll have a condition that determines when the node
should be executed. In this case, the node
will be executed if the greetings intent is
detected in the user input. The condition can
be as simple as this or a complex
logical expression. In most cases it will
test against an intent, entity, or a combination of them. Then we have the
response block where we finally get to decide what
to reply back to the user. In this case, a simple "Hi there. How can I help you?" will suffice. This response block
has many, many options. In fact, the response doesn't
even have to be text. It could be an image or some options for the
user to choose from. We can provide multiple
response variations and then decide if they
should be issued in the order they appear
every time this node is executed or randomly from
the list we provide. We can even have multiple
responses where we attach a condition to each
individual response within the same node. This is a great feature
and we'll definitely take advantage of it in
the labs of this course. Finally, we get to specify what happens after we
issued a response. Typically we just wait for
the user to say something else and that's why that's
the default action. However, other options
are available including the ability to jump to other
nodes within the dialogue. This is a feature that will be useful in more complex chatbot, but can lead to
chatbots that are difficult to reason
about if you abuse it. The execution is evaluated from the top to the
bottom of the dialogue, so when the user submits
their utterance, the first node will be
evaluated for execution. If the condition is not met, we'll move down to
the second node. If this one doesn't meet
the criteria either, we'll consider the
third node and so on. Essentially we continue to evaluate nodes in the order they appear while the conditions
of these nodes are faults. We stop at the first node whose condition matches
the user input. This is why it's
important to have that "anything else" fallback
node at the very bottom. That node has a special
condition that is always true whenever all the nodes
above it fail to execute. It ensures that we have
a reply for the user, even if it's a simple "I don't understand could
you try rephrasing?" Likewise, this is why we have the welcome node greeting
the user at the very top. That node has a special
welcome condition that is only true at the beginning of the conversation
with the user. By placing it up top, we ensure that it's
executed prior to any other node
being considered. The fact that the condition
is only true once, ensures that we
don't keep greeting the user every time we
evaluate their input. Nodes can also have
children nodes and there are situations
in complex chatbots where employing this
feature enables us to create a more nuanced chatbot. Children nodes are
considered for execution only after the parent
node has been executed, unless some other
node in the dialogue explicitly jumped to
a given child node. Children nodes are then also
executed top to bottom and we stop executing at the first child node that
meets the condition. Watson assistant introduced
many cool new features that actually allows us to rely
less on children nodes, greatly simplifying
our dialogue design. By the end of this course, you'll become familiar with
both children nodes and the simpler alternatives you can commonly use in many scenarios.